
    let sub = document.querySelector(".submitb");
    let name = document.querySelector("#usernameb");
    let pass = document.querySelector("#passwordb");

    let one = document.querySelector(".one");//登录注册
    let two = document.querySelector(".two");//欢迎，注销  
  
    sub.onclick = function(){
        let username = name.value;
        let password = pass.value;
        //cookie存入输入的名字
        setCookie('username',username,{expires:1,path:'/'});
        prom('./api/v1/user/log.php',{username,password}).then(reg =>{
            //数据库验证成功
            if(reg.code === 200){
               alert('登录成功！')
               const {list} = reg.body
                //提取数据库名字，保存cookie
                let cook = list.reduce((strs,shop,index) => {
                   // console.log(index);
                   strs = `${shop.username}`
                   return strs
                },'') 
                //保存cookie,取名name 
                setCookie('name',cook,{expires:1,path:'/'});      
            }else{
               alert('登录失败！')
            }
            setTimeout(() => {
                $('#shoplog').modal('hide')
            },20)
        })
    }
    
    //判断输入姓名username 是否等于 name 然后显示
    let mingzi1 = getCookie('username');
    let mingzi2 = getCookie('name');
    console.log(mingzi1);
    console.log(mingzi2);
    if(mingzi1 == mingzi2){
        one.classList.add('hidden')
        two.classList.remove('hidden')
        two.innerHTML = `<li><a href="">欢迎您，<b class="ming">${mingzi1}</b></a></li>
        <li class="tuichu"><a href="#">注销</a></li>`
    }

    two.onclick = function(e){
        if(e.target.tagName === 'A'){
            setCookie('username',' ',{expires:-1,path:'/'});
            one.classList.remove('hidden')
            two.classList.add('hidden')
        }
    }
              